package com.wangxiang.shop.product.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


import com.wangxiang.shop.product.entity.ClothingSpuEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wangxiang.shop.product.entity.ClothingSkuEntity;
import com.wangxiang.shop.product.service.ClothingSkuService;
import com.wangxiang.common.utils.PageUtils;
import com.wangxiang.common.utils.R;



/**
 * 
 *
 * @author wangxiang
 * @email 2293672863@qq.com
 * @date 2022-03-14 11:30:20
 */
@RestController
@RequestMapping("product/clothingsku")
public class ClothingSkuController {
    @Autowired
    private ClothingSkuService clothingSkuService;

    @RequestMapping("page")
    public R page(@RequestBody ClothingSkuEntity clothingSkuEntity){
        System.out.println(clothingSkuEntity);
        return null;
    }
    @RequestMapping("sku")
    public R getSku(@RequestBody ClothingSkuEntity skuEntity){
        if (skuEntity.getSpuId()==0){
            return R.error("索引不存在，系统错误，请联系管理员");
        }

        List<ClothingSkuEntity> skuBySpuId = clothingSkuService.getSkuBySpuId(skuEntity);
        if (skuBySpuId.size()==0){
            return R.ok().put("msg","该商品也许已下架，请联系管理员失效").put("code",700);
        }



        return R.ok().put("data",skuBySpuId);
    }


}
